package com.ruis.kotboot.api.kisso

import com.baomidou.kisso.web.interceptor.SSOPermissionInterceptor
import org.springframework.context.annotation.Configuration
import org.springframework.web.bind.annotation.ControllerAdvice
import org.springframework.web.servlet.config.annotation.InterceptorRegistry
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer


/**
 * Created by mgr on 2018/3/8.
 */

@ControllerAdvice
@Configuration
class KissoWebConfig : WebMvcConfigurer {
    override fun addInterceptors(registry: InterceptorRegistry) {
        // kisso 登录拦截器配置
        registry.addInterceptor(RuisSSOSpringInterceptor())
                .addPathPatterns("/adm/**")
                .addPathPatterns("/user/**")
                .addPathPatterns("/api/mem/**")
//                .excludePathPatterns("/login")
        // kisso 权限拦截器配置
        registry.addInterceptor(SSOPermissionInterceptor().also {
            it.isNothingAnnotationPass=true  //无注解默认不拦截
            it.authorization = KissoAuthorization()
        }).addPathPatterns("/**")
    }
}